package org.wuqi.microweb.api.testmethod;

import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author jjj
 * @program: earnest-money
 * @description:TODO
 * @date 2024-01-03 10:03:00
 */
// 验证异步同步化的操作

@Component
public class SyncThread2 {
    private Logger logger = LoggerFactory.getLogger(SyncThread2.class);
    @Async
    public void run(){
        System.out.println("==== run2 ====");
        long t1 = System.currentTimeMillis();
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        long t2 = System.currentTimeMillis();
        logger.info("task1 cost {} ms" , t2-t1);

    }
   /* @Override
    public void run() {
        System.out.println("====== run1 ======");
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }*/
}
 
 